<%@ page language="java" pageEncoding="ISO-8859-1"%>
<%@page import="java.util.Iterator"%>

<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html lang="true">
  <head>
    <html:base />
    
    <title>updatebook.jsp</title>

	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
  
  <logic:present name="afterupdate">
  <h1>The book has been successfully updated!</h1>
  <h3>New Title</h3>
  <bean:write name="afterupdate" property="title"/><br>
  <h3>New Author(s)</h3>
    <bean:define id="test" name="afterupdate" type="org.lonetree.tc.core.Book" />
  <% 
  Iterator<String> itr=test.getAuthors().iterator();
  while (itr.hasNext())
  {
	  out.println(itr.next());
	  out.println("<br>");
  }
	  %>
	  
	  <a href="javascript:history.back(-1)">Go back</a>
  </logic:present>
  
  <logic:present name="loaded">
  <form action="../UpdateBook.do" method="POST"> 
      <table border="0">
      <tr>
      <td>ISBN</td>
      <td>
      <input type="hidden" name="isbn" value="<bean:write name="loaded" property="isbn" />" /><br>
      ISBN (<bean:write name="loaded" property="isbn" />) cannot be updated. To change ISBN, please delete this book first</td>
      </tr>
        <tr>
          <td>Book Title:</td>
          <td>
          <input type="text" name="title" size="75" value="<bean:write name="loaded" property="title" />"></td>
        </tr>
        
        <tr>
          <td>Authors:</td>
          <bean:define id="a" name="loaded" type="org.lonetree.tc.core.Book" />
          <td><input type="text" name="authors" size="50" 
          value="<%
 Iterator<String> itr=a.getAuthors().iterator();
 String value="";
 while (itr.hasNext())
 {
         value=value+itr.next()+",";
 }
 		value=value.substring(0,value.length()-1);
 		out.print(value);
         %>"></td>
        </tr>
        <tr>
          <td colspan="2" align="center"><input type="submit" value="Submit"></td>
        </tr>
      </table>
    </form>
    </logic:present>
    
  </body>
</html:html>
